﻿namespace HEFramework
{
    public static class ThemeSystem
    {
        [EntitySystem]
        public class ThemeAwakeSystem : AwakeSystem<Theme, int>
        {
            protected override void Awake(Theme _self, int _a)
            {
                var dc = _self.GetSceneChild<DataTableComponent>();
                if (dc == null)
                {
                    return;
                }

                _self.ID = _a;
                var data = dc.LoadDataTable<DRTheme>().GetData(_self.ID);

                var trial = _self.GetSceneChild<Trial>();
                if (trial != null)
                {
                    for (int i = 0; i < data.TrialIDs.Length; i++)
                    {
                        trial.AddTrial(data.TrialIDs[i]);
                    }
                }

                var round = _self.GetSceneChild<Round>();
                if (round != null)
                {
                    for (int i = 0; i < data.MonsterIDs.Length; i++)
                    {
                        round.MonsterGenerateIDs.Add(data.MonsterIDs[i]);
                    }
                }
            }
        }
    }
}